package framework;

import java.sql.ResultSet;
import java.sql.SQLException;
import dbmanager.FoodManager;

// Akin to recipe_uses_food_item
// A recipe has ingredients

public class Ingredient {
	FoodItem foodItem;
	int quantity;
	String measuringUnit;

	public Ingredient(ResultSet rs)
			throws SQLException {
		foodItem = FoodManager.getFoodItem(rs.getString("food_item_name"));
		measuringUnit = rs.getString("measuring_unit");
		quantity = Integer.parseInt(rs.getString("quantity"));
	}

	public Ingredient(FoodItem foodItem, String measuringUnit, int quantity) {
		this.foodItem = foodItem;
		this.measuringUnit = measuringUnit;
		this.quantity = quantity;
	}

	public FoodItem getFoodItem() {
		return foodItem;
	}

	public void setFoodItem(FoodItem foodItem) {
		this.foodItem = foodItem;
	}

	public int getQuantity() {
		return quantity;
	}

	public void setQuantity(int quantity) {
		this.quantity = quantity;
	}

	public String getMeasuringUnit() {
		return measuringUnit;
	}

	public void setMeasuringUnit(String measuringUnit) {
		this.measuringUnit = measuringUnit;
	}

	public String toString() {
		return quantity + " " + measuringUnit + "s of " + foodItem.name;
	}
}
